package org.hxzon.blogbackup.baidu.album;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.hxzon.blogbackup.baidu.BlogReader;
import org.hxzon.util.DebugUtil;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class AlbumBackuper {
    public static final String albumListUrl = "http://hi.baidu.com/hxzon/album";
    public static final Pattern pattern = Pattern.compile("imgarr\\[len\\]=(.*)");

    public static List<BlogAlbum> exportBlogAlbumList() {
        List<BlogAlbum> albums = new ArrayList<BlogAlbum>();
        try {

            Document doc = BlogReader.get(albumListUrl);
            Element div = doc.getElementById("forimgs");
            String divStr = div.html();
//			DebugUtil.info(divStr);
            Matcher matcher = pattern.matcher(divStr);
            while (matcher.find()) {
                String matcherStr = matcher.group();
                DebugUtil.info("find," + matcherStr);
            }
        } catch (Exception e) {
            DebugUtil.error("fetch album list error", e);
        }
        return albums;
    }

    public static void main(String args[]) {
        exportBlogAlbumList();
    }
}
